//
//  ADJgSDKNativeRenderer.m
//  AnyThinkSDKDemo
//
//  Created by 刘娟 on 2024/9/25.
//  Copyright © 2024 抽筋的灯. All rights reserved.
//

#import "ADJgSDKNativeRenderer.h"
#import <ADJgSDK/ADJgSDK.h>

@interface ADJgSDKNativeRenderer ()
@property (nonatomic , strong)ATNativeADCache *offer;
@end

@implementation ADJgSDKNativeRenderer

-(__kindof UIView*)createMediaView {
    return nil;
}

-(void) renderOffer:(ATNativeADCache *)offer {
    if (self.offer == offer) {
        return;
    }
    self.offer = offer;
    [super renderOffer:offer];
    _customEvent = offer.assets[kATAdAssetsCustomEventKey];
    _customEvent.adView = self.ADView;
    self.ADView.customEvent = _customEvent;
    
    ADJgSDKNativeAd *nativeExpressAd = (ADJgSDKNativeAd *)offer.assets[@"nativeexpress_manager"];
    nativeExpressAd.delegate = _customEvent;
    nativeExpressAd.controller = self.configuration.rootViewController;
    UIView<ADJgAdapterNativeAdViewDelegate> *nativeFeed = offer.assets[kATAdAssetsCustomObjectKey];
    [nativeFeed adjg_registViews:@[nativeFeed]];
    [self.ADView addSubview:(UIView*)nativeFeed];
    nativeFeed.center = CGPointMake(CGRectGetMidX(self.ADView.bounds), CGRectGetMidY(self.ADView.bounds));
    
}

@end
